package com.kailong.servlet.student;

import com.kailong.dao.admin.ManageSeatDao;
import com.kailong.dao.admin.ManageStudentDao;
import com.kailong.pojo.Seat;
import com.kailong.pojo.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
@WebServlet("/admin/studentSelectAll")
public class StudentSelectAll extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int cpage = 1;//
        int count = 10;//
        String college = req.getParameter("college");
        String sex = req.getParameter("sex");
        String cp = req.getParameter("cp");
        if(cp!=null){
            cpage = Integer.parseInt(cp);
        }
        int arr[]  = ManageStudentDao.totalPage(count,college,sex);
        //获取所有用户记录
        ArrayList<Student> list = ManageStudentDao.selectAll(cpage,count,college,sex);
        //放到请求对象域
        req.setAttribute("studentlist",list);
        req.setAttribute("tsum",arr[0]);
        req.setAttribute("tpage",arr[1]);
        req.setAttribute("cpage",cpage);
        if(college!=null && sex != null){
            req.setAttribute("searchParams","&college=" + college + "&sex=" + sex);
        }

        req.getRequestDispatcher("adminStudentSelect.jsp").forward(req,resp);
    }
}
